From e0638f7e6219ce0a8b9d13d0396408fc40d296f9 Mon Sep 17 00:00:00 2001 From: Tim Deegan Date: Thu, 29 Mar 2007 15:27:18 +0000 Subject: [PATCH] [HVM] Save/restore: don't get guest size from "memory_static_min" since it doesn't mean that any more. This is a sticking-plaster to get HVM S/R working until the proper memory-map handling patch is ready. Signed-off-by: Tim Deegan --- tools/libxc/xc_hvm_restore.c | 29 ++++++++++--------------- tools/python/xen/xend/XendCheckpoint.py | 8 +++---- tools/xcutils/xc_restore.c | 2 -- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/tools/libxc/xc_hvm_restore.c b/tools/libxc/xc_hvm_restore.c index 4b54b0aaf5..32fa627005 100644 --- a/tools/libxc/xc_hvm_restore.c +++ b/tools/libxc/xc_hvm_restore.c @@ -81,7 +81,7 @@ int xc_hvm_restore(int xc_handle, int io_fd, unsigned int rc = 1, n, i; uint32_t rec_len, nr_vcpus; uint8_t *hvm_buf = NULL; - unsigned long long v_end, memsize; + unsigned long long v_end; unsigned long shared_page_nr; unsigned long pfn; @@ -91,16 +91,19 @@ int xc_hvm_restore(int xc_handle, int io_fd, /* Types of the pfns in the current region */ unsigned long region_pfn_type[MAX_BATCH_SIZE]; - /* Number of pages of memory the guest has. *Not* the same as max_pfn. */ - unsigned long nr_pages; - /* The size of an array big enough to contain all guest pfns */ unsigned long pfn_array_size = max_pfn + 1; - /* hvm guest mem size (Mb) */ - memsize = (unsigned long long)*store_mfn; - v_end = memsize << 20; - nr_pages = (unsigned long) memsize << (20 - PAGE_SHIFT); + /* Number of pages of memory the guest has. *Not* the same as max_pfn. */ + unsigned long nr_pages = max_pfn + 1; + /* MMIO hole doesn't contain RAM */ + if ( nr_pages >= HVM_BELOW_4G_MMIO_START >> PAGE_SHIFT ) + nr_pages -= HVM_BELOW_4G_MMIO_LENGTH >> PAGE_SHIFT; + /* VGA hole doesn't contain RAM */ + nr_pages -= 0x20; + + /* XXX: Unlikely to be true, but matches previous behaviour. :( */ + v_end = (nr_pages + 0x20) << PAGE_SHIFT; DPRINTF("xc_hvm_restore:dom=%d, nr_pages=0x%lx, store_evtchn=%d, " "*store_mfn=%ld, pae=%u, apic=%u.\n", @@ -146,7 +149,7 @@ int xc_hvm_restore(int xc_handle, int io_fd, 0, 0, &pfns[0x00]); if ( (rc == 0) && (nr_pages > 0xc0) ) rc = xc_domain_memory_populate_physmap( - xc_handle, dom, nr_pages - 0xc0, 0, 0, &pfns[0xc0]); + xc_handle, dom, nr_pages - 0xa0, 0, 0, &pfns[0xc0]); if ( rc != 0 ) { PERROR("Could not allocate memory for HVM guest.\n"); @@ -276,14 +279,6 @@ int xc_hvm_restore(int xc_handle, int io_fd, else shared_page_nr = (v_end >> PAGE_SHIFT) - 1; - /* Paranoia: clean pages. */ - if ( xc_clear_domain_page(xc_handle, dom, shared_page_nr) || - xc_clear_domain_page(xc_handle, dom, shared_page_nr-1) || - xc_clear_domain_page(xc_handle, dom, shared_page_nr-2) ) { - ERROR("error clearing comms frames!\n"); - goto out; - } - xc_set_hvm_param(xc_handle, dom, HVM_PARAM_STORE_PFN, shared_page_nr-1); xc_set_hvm_param(xc_handle, dom, HVM_PARAM_BUFIOREQ_PFN, shared_page_nr-2); xc_set_hvm_param(xc_handle, dom, HVM_PARAM_IOREQ_PFN, shared_page_nr); diff --git a/tools/python/xen/xend/XendCheckpoint.py b/tools/python/xen/xend/XendCheckpoint.py index 3982188016..4b22ecc04f 100644 --- a/tools/python/xen/xend/XendCheckpoint.py +++ b/tools/python/xen/xend/XendCheckpoint.py @@ -192,13 +192,11 @@ def restore(xd, fd, dominfo = None, paused = False): image_cfg = dominfo.info.get('image', {}) is_hvm = dominfo.info.is_hvm() if is_hvm: - hvm = dominfo.info['memory_static_min'] apic = int(dominfo.info['platform'].get('apic', 0)) pae = int(dominfo.info['platform'].get('pae', 0)) - log.info("restore hvm domain %d, mem=%d, apic=%d, pae=%d", - dominfo.domid, hvm, apic, pae) + log.info("restore hvm domain %d, apic=%d, pae=%d", + dominfo.domid, apic, pae) else: - hvm = 0 apic = 0 pae = 0 @@ -224,7 +222,7 @@ def restore(xd, fd, dominfo = None, paused = False): cmd = map(str, [xen.util.auxbin.pathTo(XC_RESTORE), fd, dominfo.getDomid(), max_pfn, - store_port, console_port, hvm, pae, apic]) + store_port, console_port, int(is_hvm), pae, apic]) log.debug("[xc_restore]: %s", string.join(cmd)) handler = RestoreInputHandler() diff --git a/tools/xcutils/xc_restore.c b/tools/xcutils/xc_restore.c index 0eaf3210a3..a2cf9c115f 100644 --- a/tools/xcutils/xc_restore.c +++ b/tools/xcutils/xc_restore.c @@ -42,8 +42,6 @@ main(int argc, char **argv) apic = atoi(argv[8]); if (hvm) { - /* pass the memsize to xc_hvm_restore to find the store_mfn */ - store_mfn = hvm; ret = xc_hvm_restore(xc_fd, io_fd, domid, max_pfn, store_evtchn, &store_mfn, pae, apic); } else -- 2.30.2